package cn.sinata.wanglin.mine.activity;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.bigkoo.pickerview.TimePickerView;
import com.xilada.xldutils.activitys.RecyclerListActivity;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.sinata.wanglin.R;
import cn.sinata.wanglin.adapter.WithdrawalsRecordsAdapter;
import cn.sinata.wanglin.model.WithdrawalsRecords;

public class RechargeWithdrawalsRecordsActivity extends RecyclerListActivity implements View.OnClickListener {

    private TextView tvStartTime;
    private TextView tvEndTime;
    private List<WithdrawalsRecords> mWithdrawalsRecordss = new ArrayList<>();
    private WithdrawalsRecordsAdapter mWithdrawalsRecordsAdapter ;
    private String userId;
    private int pageIndex = 1;
    private long startTime = 0;
    private long endTime = 0;

    @Override
    protected void initView() {
        super.initView();
        setTitle("提现记录");
        View view = View.inflate(this, R.layout.head_withdrawalsrecords_list,null);
        tvStartTime = (TextView) view.findViewById(R.id.tv_startTime);
        tvEndTime = (TextView) view.findViewById(R.id.tv_endTime);
        TextView btnSearch = (TextView) view.findViewById(R.id.search);
        addView(1,view);
        setItemDecoration(DEFAULT_DIVIDER);
        tvStartTime.setOnClickListener(this);
        tvEndTime.setOnClickListener(this);
        btnSearch.setOnClickListener(this);
    }
    @Override
    protected RecyclerView.Adapter setAdapter() {
        mWithdrawalsRecordss.add(new WithdrawalsRecords());
        mWithdrawalsRecordss.add(new WithdrawalsRecords());
        mWithdrawalsRecordss.add(new WithdrawalsRecords());
        mWithdrawalsRecordss.add(new WithdrawalsRecords());
        mWithdrawalsRecordss.add(new WithdrawalsRecords());
        mWithdrawalsRecordsAdapter=new WithdrawalsRecordsAdapter(mWithdrawalsRecordss);
        return mWithdrawalsRecordsAdapter;
    }

    @Override
    protected void pullDownRefresh() {

    }

    @Override
    protected void loadMore() {

    }
    /**
     * 选择时间
     * @param type 0开始时间，1结束时间
     */
    private void selectTime(final int type){

    }
    /**
     * 选择时间;
     */
    private void choiceBornTime() {
        //起始时间的选择
        TimePickerView pvTime = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //控制时间范围
//        Calendar calendar = Calendar.getInstance();
//        pvTime.setRange(calendar.get(Calendar.YEAR) - 20, calendar.get(Calendar.YEAR));//要在setTime 之前才有效果哦
        pvTime.setTime(new Date());
        pvTime.setCyclic(false);
        pvTime.setCancelable(true);
        //时间选择后回调
        pvTime.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                showToast(getTime(date));
            }
        });
        pvTime.show();
    }
    public static String getTime(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return format.format(date);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_startTime:
                selectTime(0);
                break;
            case R.id.tv_endTime:
                selectTime(1);
                break;
            case R.id.search:
                break;

        }
    }
}
